import request from '../utils/request'

// 获取历史消息
export const getMessageHistory = (senderId, receiverId) => {
  return request({
    url: '/messages/history',
    method: 'get',
    params: {
      senderId,
      receiverId
    }
  })
}

// 发送消息
export const sendMessage = (data) => {
  return request({
    url: '/messages/send',
    method: 'post',
    data
  })
}

// 获取用户的所有消息列表（发送或接收）
export const getMessageList = (userId) => {
  return request({
    url: `/messages/${userId}`,
    method: 'get'
  })
}

// 添加新的API方法
export const markMessageAsRead = (messageId) => {
  return request({
    url: '/messages/read',
    method: 'put',
    data: { messageId }
  })
}

// 进入消息详情页时，标记所有消息为已读 
export const markMessagesAsRead = (senderId) => {
  return request({
    url: `/messages/read/${senderId}`,
    method: 'put',
    data: { senderId }
  })
} 